

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import com.xiaoy.core.bpm.engine.activiti.activiti5.WorkFlowActiviti5Impl;
import com.xiaoy.core.bpm.engine.api.WorkFlow;
import com.xiaoy.core.bpm.engine.entity.InstanceProcessVO;
import com.xiaoy.core.bpm.engine.entity.ProcessDefineVO;

public class Test {

	
	WorkFlowActiviti5Impl wf;
	public Test() {
		wf = (WorkFlowActiviti5Impl) SpringUtil.getService("workFlowActiviti5Impl");
	}
	
	
	public void defineList () {
		wf.getAllProcessDefinitions();
	}
	
	/**
	 * 定义的流程
	 */
	public void defineProcess (){
		
		try {
			String name = "p1"+".bpmn";
			FileInputStream fis = new FileInputStream("C:\\Users\\chentianyi\\Desktop\\bpm\\"+name);
			ProcessDefineVO vo = wf.defineProcess(name,fis);
//			wf.defineProcess();
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	/**
	 * 实例化一个流程
	 */
	public void instanceProcess () {
		
		
		InstanceProcessVO vo = new InstanceProcessVO();
//		vo.addParam("username","cty");
		vo.addParam(WorkFlow.APPLY_USER,"cty");
		vo.addParam("chener", "chener");
//		String id = "myProcess:1:1004";
//		vo.setId(id);
//		wf.createProcessInstanceById(vo);
		
		String key = "p_test1";
		vo.setKey(key);
		wf.createProcessInstanceById(vo);
		
	}
	
	/**
	 * 我的待办
	 */
	public void myTasks () {
		wf.getTaskByUsername("cty");
	}
	
	public void approve(){
		
	}
	
	
	/**
	 * 我的申请的流程
	 */
	public void myApplied () {
		
	}
	
	
	public void processInfo () {
		
		wf.getProcessNodesByDefineId("myProcess:1:4");
		
	}
	
	
	
	public static void main(String[] args) {
		try {
			Test test = new Test();
//			test.defineProcess();
//			test.defineList () ;
//			test.instanceProcess ();
//			test.myTasks ();
			
			test.processInfo();
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}


